<?php if (!defined('BASEPATH')) exit('No direct script access allowed');
function pdf_create($html, $filename='', $stream=TRUE) 
{
    require_once("dompdf/dompdf_config.inc.php");
   
    $dompdf = new DOMPDF();
    $dompdf->load_html($html);
    $dompdf->render();
    if ($stream) {
        //$dompdf->stream($filename.".pdf",array("Attachment" => 0,"paper"=>"letter"));
        $pdf = $dompdf->output();
       file_put_contents("tmp/".$filename, $pdf);
       //$dompdf->stream($filename.".pdf", array("Attachment" => 0));
    } else {
        return $dompdf->output();
    }
}

// function pdf_create($html, $filename, $stream=TRUE)
// {
// 	require_once("dompdf/dompdf_config.inc.php");

// 	$dompdf = new DOMPDF();
// 	$dompdf->load_html($html);
// 	$dompdf->render();
// 	if ($stream) {
// 		$dompdf->stream($filename.".pdf");
// 	} else {
// 		//$CI =&get_instance();
		
// 		write_file("invoice_1.pdf", $dompdf->output());
// 	}
// }


// /**
//  * Try increasing memory available, mostly for PDF generation
// */
// ini_set("memory_limit", "32M");

// function pdf_create($html, $filename, $stream=TRUE, $orientation="portrait") {
// 	//require_once(BASEPATH . "application/helpers/dompdf/dompdf_config.inc.php");
// 	require_once("dompdf/dompdf_config.inc.php");
	
// 	$dompdf = new DOMPDF();
// 	$dompdf->set_paper("a4", $orientation);
// 	$dompdf->load_html($html);
// 	$dompdf->render();
// 	if ($stream) { //open only
// 		$dompdf->stream($filename . ".pdf");
// 	} else { // save to file only, your going to load the file helper for this one
// 		write_file("pdf/$filename.pdf", $dompdf->output());
// 	}
// }




?>